package com.adinnet.common.biz.enums;

/**
 * @author yubin
 * @date 2020/8/4 10:52
 */
public enum ValidType {
    PUTAWAY(1, "上架"),
    SOLDOUT(2, "下架");

    private Integer code;
    private String name;

    ValidType(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 根据code获取name
     * @param code
     * @return
     */
    public static String getNameByCode(Integer code){
        for(ValidType validType: ValidType.values()){
            if(code.equals(validType.getCode())){
                return validType.getName();
            }
        }
        return  null;
    }

}
